package com.yuexun.dhdoctor.module.mythings.presenter.impl;



import com.yuexun.dhdoctor.module.mythings.bean.TaskData;
import com.yuexun.dhdoctor.module.mythings.model.IThingDetailModel;
import com.yuexun.dhdoctor.module.mythings.presenter.IThingDetailPresenter;
import com.yuexun.dhdoctor.module.mythings.ui.view.IThingDetailView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/8/31.
 */
public class ThingDetailPresenter implements IThingDetailPresenter {
    private IThingDetailView view;
    private IThingDetailModel model;

        //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

        public ThingDetailPresenter(IThingDetailModel model, IThingDetailView view) {
            this.model = model;
            this.view = view;
        }


    @Override
    public void getTaskDetailDatas(Map<String, String> praise) {
        model.getTaskDetailDatas(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<TaskData>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("请检查网络状态");
                    }

                    @Override
                    public void onNext(TaskData taskData) {
                        view.showTaskDetailDatas(taskData);
                    }
                });
    }

}
